package com.learn.jdk;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.function.BiFunction;
import java.util.stream.Collectors;

/**
 * Copyright: Copyright (c) 2019 Asiainfo
 *
 * @ClassName: com.learn.jdk.TestPredicate
 * @Description: 该类的功能描述
 * @version: v1.0.0
 * @author: lipan
 * @date: 2019/11/4 16:12
 * <p>
 * Modification History:
 * Date         Author          Version            Description
 * ------------------------------------------------------------
 * 2019/11/4      lipan          v1.0.0               修改原因
 */

public class TestPredicate {


    public static void main(String[] args) {

        Person p1 = new Person(22,"like");
        Person p2= new Person(22,"liwang");
        Person p3 = new Person(18,"luobotei");

        List<Person> people = Arrays.asList(p1, p2, p3);

        System.out.println(filterName("li", people));

        System.out.println(filterAge(20, people));


    }


    public static List<Person> filterName(String name,List<Person> list){
         return  list.stream().filter(person->person.getName().startsWith("li")).collect(Collectors.toList());
    }



    public static List<Person> filterAge(int age,List<Person> list){
        BiFunction< Integer ,List<Person>,List<Person>> biFunction=(define,personList)->personList.stream().filter(person -> person.getAge()>define).collect(Collectors.toList());
         return  biFunction.apply(age,list);
     }





}
